import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/layout';

/* login */
const Login = _import('login/index');
// const authRedirect = _import('login/authredirect');

/* finder */
const Finder = _import('finder/index');

/* Account & Group */
const Account = _import('account/index');
const Group = _import('group/index');

/* Log */
const Log = _import('log/index');

Vue.use(Router)

 /**
  * icon : the icon show in the sidebar
  * hidden : if hidden:true will not show in the sidebar
  * redirect : if redirect:noredirect will not redirct in the levelbar
  * noDropdown : if noDropdown:true will not has submenu
  * meta : { role: ['admin'] }  will control the page role
  **/

export const constantRouterMap = [
  { path: '/login', component: Login, hidden: true },
  // { path: '/authredirect', component: authRedirect, hidden: true },
  // { path: '/404', component: Err404, hidden: true },
  // { path: '/401', component: Err401, hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/finder',
    name: 'finder',
    children: [{ path: 'finder', component: Finder }]
  }
]

export default new Router({
  mode:'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})


export const asyncRouterMap = [
  {
    path: '/account',
    component: Layout,
    redirect: '/account/index',
    name: '用户管理',
    meta: { role: ['admin','group_admin'] },
    children: [{ path: 'index', component: Account, name: '用户管理页', meta: { role: ['admin', 'group_admin'] } }]
  },
  {
    path: '/group',
    component: Layout,
    redirect: '/group/index',
    name: '群组管理',
    meta: { role: ['admin','group_admin'] },
    children: [{ path: 'index', component: Group, name: '群组管理页', meta: { role: ['admin', 'group_admin'] } }]
  },
  {
    path: '/log',
    component: Layout,
    redirect: '/log/index',
    name: '日志管理',
    meta: { role: ['admin'] },
    children: [{ path: 'index', component: Log, name: '日志管理页', meta: { role: ['admin'] } }]
  }
  //{ path: '*', redirect: '/404', hidden: true }
];
